<?php if (!defined('THINK_PATH')) exit();?><style type="text/css">
	.update_tb tr{
		height:30px;
	}
	.label{
		padding:0 5px 0 10px;
	}
	.labels{
		font-size: 12px;
    font-weight: bold;
    color: #0E2D5F;
    height: 16px;
	}
	/* 上传btn修改样式 */
.uploadify-button {
    border: 1px solid #F3EEEE;
    background-color:rgba(102, 174, 236, 0.91);
    line-height: 30px;
    border-radius: 4px;
    font-size: 15px;
}

.uploadify-button:hover {
    background-color:#EF5959; 
}
.rowStyle{
	background-color: red;
}
.validatebox-readonly{
	/*background-color: rgba(208, 206, 206, 0.37);*/
}
</style>

<!-- 上传窗口 -->
		<div id="add_ggd" class="easyui-dialog" style="width: 728px; height: 130px; padding: 0px; overflow: hidden;" title="&nbsp;&nbsp;导入更改单信息" data-options="iconCls:'icon-standard-folder-page',buttons:'#dlg-add',closed:true,resizable:false,modal:true,closable:true">
			<div id="url">
			</div>
			<input type="hidden" name="urltext" class="form-control" id='urltext' value="" />
		</div>
		<div id="dlg-add">
			<div class="tool_tip">
				选择文件后系统会自动上传！！
			</div>
			<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="javascript:$('#add_ggd').dialog('close')">取消</a>
		</div>


<div id="ccaa" class="easyui-layout" data-options="fit:true,border:false">   
    <div data-options="region:'center',title:'',border:false" style="padding:5px;background:#eee;">
    	
			<table id="dgggd"></table>


    </div>
     <div data-options="region:'south',title:'编辑更改单(标题为蓝色的是需要选择填写的)',split:true,border:false,iconCls:'icon-standard-page-white-paint',hideCollapsedContent:false" style="height:290px;">
     	
     	<div style="padding:10px 20px 20px 5px">
	    <form id="update_form" method="post">
	    	<table cellpadding="5" class="update_tb">
	    		<tr>
					<td>
		    			<input  id="id" name="id" type= "hidden"/> 
		    			<span class="label">更改编号:</span><input  id="changenum" name="changenum" type= "text" data-options="iconCls:'icon-standard-text-list-numbers',readonly:'true',editable:'false',iconAlign:'left'" style="width:160px" class="easyui-textbox" /> 
		    			<span class="label">设计人员:</span><input  id="designer" name="designer" type= "text" data-options="iconCls:'icon-standard-user-suit',readonly:'true',editable:'false',iconAlign:'left'" style="width:100px" class="easyui-textbox" /> 
		    			<span class="label">修改时间:</span> 
		    			<input class="easyui-datetimebox" id="changetime" name="changetime"     
	        data-options="required:true,showSeconds:false,readonly:'true',editable:'false',iconAlign:'left'" value="3/4/2010 2:3" style="width:150px" />  
		    			<span class="label">更改对象:</span> <input  id="info" name="info" type= "text" data-options="iconCls:'icon-standard-transmit',readonly:'true',editable:'false',iconAlign:'left'" style="width:120px" class="easyui-textbox" /> 
		    		</td>
	    		</tr>
	    		<tr>
	    			<td>
	    				<span class="label">更改单名称:</span> <input  id="name" name="name" type= "text" data-options="iconCls:'icon-standard-text-lowercase',readonly:'true',editable:'false',iconAlign:'left'" style="width:200px" class="easyui-textbox" />
	    				<span class="label">负责人员:</span> 
	    				<input  id="dutyperson" name="dutyperson" type= "text" data-options="iconCls:'icon-standard-text-lowercase',readonly:'true',editable:'false',iconAlign:'left'" style="width:200px" class="easyui-textbox" />
    					 
					<!-- 	<input id="dutyperson" class="easyui-combobox" name="dutyperson"   
    data-options="valueField:'value',textField:'text',url:'/solve/index.php/Home/Ggd/user',required:true,iconAlign:'left',editable:false" style="width:120px;"/>  -->
						<span class="label labels">处理方式:</span>

						<input id="handlemethod" name="handlemethod" style="width:240px;" required ="required"/> 
	    			</td>	    	
	    		</tr>
				<tr>
					<td>
					<span class="label">更改说明:</span>
						<input id="smm" name="smm"  data-options="editable:false,multiline:true"  style="width:90%;height:60px;"  class="easyui-textbox">  


					</td>
				</tr>
				<tr>
					<td>
					<span class="label labels">备注记录:</span>
						<input id="note" name="note"  data-options="iconCls:'icon-standard-table-multiple',prompt:'请输入备注...',iconAlign:'left'" style="width:90%"  class="easyui-textbox" >   

					</td>
				</tr>
	    		<tr>	    			
	    			<td>
					<span class="label">处理时间:</span>
					<input  id="handletime"  name="handletime" type= "text" data-options="readonly:'true',editable:'false'"  class= "easyui-datebox"  /> 
					
<span class="label labels">是否处理完毕:</span>

					 <select id="over" name="over"  class="easyui-combobox" name="dept" style="width:60px;" data-options="panelHeight:'auto',editable:false">   
    <option value="1">是</option> 
    <option value="0">否</option>    
</select> 
	    			</td>



	    		</tr> 		
	    	</table>
	    </form>
	    <div style="text-align:center;padding:5px">
	    	<a href="javascript:void(0)" id="update" class="easyui-linkbutton" onclick="edit()">确认提交</a>

	    </div>
	    </div>
     </div>    
</div> 

<!-- 任务分配窗口  -->
<div id="fp" class="easyui-dialog" title="&nbsp;&nbsp;重新分派处理人" style="width:400px;height:150px;padding:25px;"   
        data-options="iconCls:'icon-standard-user-add',buttons:'#dfp-tool',resizable:false,modal:true,closable:true,closed:true" >   
     <span>请选择要重新你分派的工艺员：</span>
    <input id="dutypersonfp"  class="easyui-combobox" name="dutyperson"   
    data-options="valueField:'value',textField:'text',url:'/solve/index.php/Admin/Public/user',required:true,iconAlign:'left',editable:false" style="width:120px;"/>  
</div>  

<div id="dfp-tool">
			<div class="tool_tip">
				

			</div>
			<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="fp()">确认</a>
			<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="javascript:$('#fp').dialog('close')">取消</a>
		</div>
<!--工具栏 -->
<style>

	.finaSeDiv{
		float:left;
		padding:10px 0 5px 10px;
		width:200px;
	}
	.finaSeDiv label{
		width:53px;
		float: left;
	}
	.table-btn-separator {
    float: center;
    border-top: 1px solid #ccc;
    border-bottom: 1px solid #fff;
  /*  width: 1200px;*/
}
</style>

<div id="toolggd">    

<table>
<tr>

	<?php if(authCheck1('Home/Ggd/import')): ?><td>

	<a href="#" id= "aaa1" class="easyui-linkbutton"  onclick='show_add_ggd()' data-options="iconCls:'icon-standard-folder-page',plain:true">导入</a> 


 </td>


				 <td>
     <div class="datagrid-btn-separator"></div>
 </td><?php endif; ?>

<td>

	<a href="#"  class="easyui-linkbutton"  onclick='feipei()' data-options="iconCls:'icon-standard-user-add',plain:true">任务分配</a> 

 </td>


				 <td>
     <div class="datagrid-btn-separator"></div>
 </td>
 <td>


 日期：<input id="start_date" type="text" class="easyui-datebox" style="width:100px;"></input>  到
 <input id="end_date" type="text" class="easyui-datebox" style="width:100px;"></input>  

   
   

	 负责人：
<input id="dutyperson_s" class="easyui-combobox" name="dutyperson_s"   
    data-options="valueField:'value',textField:'text',url:'/solve/index.php/Admin/Public/user',panelHeight:'auto'" style="width:100px;"/>  


  

	 是否处理：<!-- <input id="over_s" name="over_s" class="easyui-switchbutton" data-options="onText:'是',offText:'否',checked:'false'"> -->

	 <select id="over_s" name="over_s" class="easyui-combobox" name="dept" style="width:60px;" data-options="panelHeight:'auto',editable:false">   
    <option value="">全部</option> 
    <option value="1">是</option> 
    <option value="0">否</option>    
</select>  

编号检索：<input id="changenum_s" name="changenum_s" class="easyui-textbox" data-options="" style="width:100px"> 


	  <a href="#" class="easyui-linkbutton"  onclick="search_ggd()" data-options="iconCls:'icon-search',plain:'true'">搜索</a> 
   </td>
   <td>
     <div class="datagrid-btn-separator"></div>
 </td>
   <td>

	  <a href="#" class="easyui-linkbutton"  onclick="reload()" data-options="iconCls:'icon-standard-arrow-refresh',plain:true">刷新</a> 

   </td>
   		 <td>
     <div class="datagrid-btn-separator"></div>
 </td>



</tr>

</table>





</div>


<style>
	.ditTitle{
		width:60px;font-weight:bold;color:#0E2D51;
		background-color: #F4F4F4
	}
	.hfs{
		text-align: center;
		font-weight: bold;
		padding: 5px 0;
		color:#0E2D51;
		background-color: #F4F4F4
	}
	.hfr{
		font-weight: bold;
		padding-left:5px; 
	}
	.hfnr{
		padding:5px 2px 5px 15px; 
	}
	/*细节栏中的图片缩略图*/
	.picsl{
		width: 40px;
		padding:0 5px;
	}
	.picsl:hover{
		border:solid 1px #95B8E7;
		width: 35px;
		cursor: hand;
	}
	.pics2{
		max-width: 150px;
		max-height: 200px;
		padding:0 5px;

	}
</style>

<script type="text/javascript">
	$('#dgggd').datagrid({
	url : '/solve/index.php/Home/Ggd/read',
	toolbar : '#toolggd',
	pagination : true,
	fit : true,
	width : function() {
		return document.body.clientWidth * 0.9
	},
	nowrap : true,//
	collapsible : true,
	fitColumns : false,
	autoRowHeight : true,
	striped : true,//交替行
	singleSelect : true,//只允许选择一行
	rownumbers : true,
	border : false,
	sortName : 'id',
	sortOrder : 'desc',//倒序排列
	remoteSort : false,
	pageSize : 15,
	method : "post",
	pageList : [ 10, 15, 20, 40, 50, 100, 200 ],
	columns : [ [
			{
				field : 'id',
				checkbox : true
			},{
				field : 'changenum',
				title : '更改单编号',
				width : 110,
				align : 'left',
        sortable:true

    },
			{
				field : 'name',
				title : '更改单名称',
				width : 240,
				align : 'left'
				
			},

			{
				field : 'smm',
				title : '更改说明',
				width : 240,
				align : 'left'
				
			},{
				field : 'designer',
				title : '设计人员',
				width : 80,
				align : 'left'
				
			},{
            field : 'changetime',
            title : '创建时间',
            width : 140,
            align : 'left',
            formatter: function(value,row,index){
                return value.substring(0,16);
            }

        },{
            field : 'drtime',
            title : '导入时间',
            width : 140,
            align : 'left',
            sortable:true,
            formatter: function(value,row,index){
                if(value){
                    return value.substring(0,16);
                }else{
                    return '';
                }

            }

        },{
            field : 'fftime',
            title : '设计更改发放时间',
            width : 140,
            align : 'left',
            sortable:true,
            formatter: function(value,row,index){
                if(value){
                    return value.substring(0,16);
                }else{
                    return '';
                }

            }

        },{
				field : 'info',
				title : '更改对象',
				width : 80,
				align : 'left'
				
			}
			,{
				field : 'dutyperson',
				title : '任务分派',
				width : 55,
				align : 'center'
				
			}
			,{
				field : 'dutyconfirm',
				title : '处理确认',
				width : 55,
				align : 'center'
				
			}
			,{
				field : 'over',
				title : '是否完成',
				width : 55,
				align : 'center',
				formatter: function(value,row,index){
					if(value==1)
						return '是';
					return '否';		
			}
				
			}
			,{
				field : 'handletime',
				title : '处理日期',
				width : 90,
				align : 'left'
				
			},{
				field : 'handlemethod',
				title : '处理方式',
				width : 200,
				align : 'left',
				formatter: function(value,row,index){
					
					return value;		
			}
				
			},
			{
				field : 'note',
				title : '备注记录',
				width : 200,
				align : 'left'
				
			}



	] ],
	  onDblClickRow: function (rowIndex, rowData) { 
	 


	  	if(rowData){

	  	}else{
	  		console.log("没有数据！");
	  	}
	  },
	     onSelect:function(index,row){
    	$('#update_form').form('load',row);
    	if(row.over==1){
    		$('#over').combobox('setValue', 1);
    	}else{
    		$('#over').combobox('setValue', 0);


    	}
		if(row.handletime==null){
			date=new Date(new Date()).Format("yyyy-MM-dd");
			$('#handletime').datebox('setValue', date);
		}

    },
    rowStyler: function(index,row){
		if (row.over==1){
			return 'background-color:#BCD1EA;color:#fff;';
   // rowStyle是一个已经定义了的ClassName(类名)
		}
	}





});
$('#handlemethod').combogrid({    
    delay: 500,    
    mode: 'remote', 
    panelWidth:650,      
    url: '/solve/index.php/Admin/Public/handlemethod',    
    idField: 'name',    
    textField: 'name', 
    editable:false,   
    columns: [[ 
    {field:'id',title:'',width:20,sortable:true},   
    {field:'name',title:'更改方式',width:200,sortable:true},    
    {field:'sm',title:'说明',width:400,sortable:true}    
    ]]    
}); 


/**
 * [onUploadStart 上传更改单]

 * @return {[type]}                   [上传更改单]
 */
$('#url').Huploadify({
    auto: true,//是否开启自动上传
    fileTypeExts: '*.xls',
    multi: false,//是否允许选择多个文件
    //formData:{key:123456,key2:'vvvv'},
    fileSizeLimit: 21024,//允许上传的文件大小，单位KB
    showUploadedPercent: true,//是否实时显示上传的百分比，如20%
    showUploadedSize: true,//是否实时显示已上传的文件大小，如1M/2M
    removeTimeout: 1000,//上传完成后进度条的消失时间，单位毫秒
    uploader: '/solve/index.php/Home/Ggd/import',//文件提交的地址
    buttonText: '导入更改单信息',//上传按钮上的文字
    onUploadStart: function(file){
        // console.log(file.name + '开始上传');
    },
    onInit: function(obj){
        // console.log('初始化');
        // console.log(obj);
    },
    onUploadComplete: function(fileObj){
        fileN = fileObj.name;
        fileSize = fileObj.size;
        fileType = fileObj.type;
        document.getElementById("urltext").value = fileN;
        //          document.getElementById("name").value = fileN;
        //          $("#name")[0].focus();
        // console.log(fileObj.name + '上传完成');
        reload();
        $('#add_ggd').window('close');
    }
    
});

		Date.prototype.Format = function(fmt) { //author: meizz 
		var o = {
			"M+" : this.getMonth() + 1, //月份 
			"d+" : this.getDate(), //日 
			"h+" : this.getHours(), //小时 
			"m+" : this.getMinutes(), //分 
			"s+" : this.getSeconds(), //秒 
			"q+" : Math.floor((this.getMonth() + 3) / 3), //季度 
			"S" : this.getMilliseconds()
		//毫秒 
		};
		if (/(y+)/.test(fmt))
			fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "")
					.substr(4 - RegExp.$1.length));
		for ( var k in o)
			if (new RegExp("(" + k + ")").test(fmt))
				fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k])
						: (("00" + o[k]).substr(("" + o[k]).length)));
		return fmt;
	}

/**
 * @description 显示导入窗口
 */
function show_add_ggd(){
    $('#add_ggd').window('open');
}


function reload() {
	$('#dgggd').datagrid('reload', {   
	    changenum: '' 
	});
}
	
 	function edit() {
		var row = $("#dgggd").datagrid("getSelected");
// if(row.over==0){
var okStatus=$('#over').combobox('getValue');


$('#update_form').form('submit', {
			type:'POST',
			 url : '/solve/index.php/Home/Ggd/edit',
			success : function(data) {
				$("#dgggd").datagrid("reload");
				$.messager.alert('提交更改单信息', data, 'info');


			}
		});

	} 


	
	/**
	/*
	**/
	function search_ggd(){
		// 获取over的状态

		$('#dgggd').datagrid('load',{
			 start_date:$("#start_date").datebox('getValue'),
			 end_date:$("#end_date").datebox('getValue'),
			dutyperson:$('#dutyperson_s').combobox('getValue'),
			 over:$('#over_s').combobox('getValue'),
			 changenum:$('#changenum_s').textbox('getText')
			
			 });

		

	}
	// 任务重新分配显示
	function feipei(){
		var row = $("#dgggd").datagrid("getSelected");
		if (row) {
			if(row.over==1){
$.messager.alert("处理人分派", "此更改单信息已经处理，不能重新分派处理人！", "info");
			}else{
				$('#dutypersonfp').combobox('setValue',row.dutyperson);
$('#fp').window('open');
			}	
		
	}else{
		$.messager.alert("处理人分派", "请选择要重新分派的行！", "info");
	}
	}

function fp(){
	var row = $("#dgggd").datagrid("getSelected");
	var person=$('#dutypersonfp').combobox('getValue');
	    $.post("/solve/index.php/Home/Ggd/fp",{id:row.id,dutyperson:person},function(result){
                 // $("span").html(result);

                 if(result.status=='1'){
                 	$("#dgggd").datagrid("reload");
                 	$('#fp').window('close');
                    $.messager.alert('分派处理人', result.data, 'info');
                 }else{
                    $.messager.alert('分派处理人', result.data, 'info');
                 }

            },"json");
}
</script>